package com.wkh.maker.generator.file;

import java.io.File;

/**
 * @author wkh
 * 核心生成器
 */
public class FileGenerator {
    public static void doGenerator(Object model){
        String propertyPath = System.getProperty("user.dir");
        File parentFile = new File(propertyPath).getParentFile();
        String inputPath = new File(parentFile, "xinyuanyi-generator-demo-projects"+File.separatorChar+"acm-template").getPath();
        String outPutPath = propertyPath;
        //静态文件生成
        StaticFileGenerator.copyFilesByHutool(inputPath,outPutPath);

        //拿到模板文件的路径
        String inputPathDynamically = propertyPath + File.separatorChar + "src/main/resources/templates/MainTemplate.java.ftl";
        //生成的文件的路径
        String outputPathDynamically = outPutPath + File.separatorChar + "acm-template/src/com/yupi/acm/MainTemplate.java";
        //生成动态文件
        try {
            DynamicFileGenerator.doGenerator(inputPathDynamically,outputPathDynamically,model);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
